package longrise.phone.com.bjjt_henan.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.longrise.LEAP.Base.Objects.EntityBean;

import longrise.phone.com.bjjt_henan.R;

/**
 * 违章查询列表的适配器
 */
public class PeccancyAdapter extends BaseAdapter {

    private Context mContext;

    private EntityBean[] lists;

    public PeccancyAdapter(Context context) {
        this.mContext = context;
    }

    public void setData(EntityBean[] beans) {
        this.lists = beans;
    }

    @Override
    public int getCount() {
        return (lists == null) ? 0 : lists.length;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (null == convertView) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.adapter_peccancy_item, null);
            holder.timeTV = (TextView) convertView.findViewById(R.id.peccancy_tv_time);
            holder.addTV = (TextView) convertView.findViewById(R.id.peccancy_tv_add);
            holder.scoreTV = (TextView) convertView.findViewById(R.id.peccancy_tv_score);
            holder.payTV = (TextView) convertView.findViewById(R.id.peccancy_tv_pay);
            holder.infoTV = (TextView) convertView.findViewById(R.id.peccancy_tv_info);
            holder.policeTV = (TextView) convertView.findViewById(R.id.peccancy_tv_police);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        //设置数据
        EntityBean bean = lists[position];
        holder.timeTV.setText(bean.getString("time"));
        holder.addTV.setText(bean.getString("address"));
        holder.scoreTV.setText(bean.getString("degree") + "分");
        holder.payTV.setText(bean.getString("money") + "元");
        holder.infoTV.setText(bean.getString("reason"));
        holder.policeTV.setText(bean.getString("department"));

        return convertView;
    }

    private class ViewHolder {
        private TextView timeTV;
        private TextView addTV;
        private TextView scoreTV;
        private TextView payTV;
        private TextView infoTV;
        private TextView policeTV;
    }
}
